﻿Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Text.RegularExpressions

Public Class Helper

    Public Shared Function ConvertYearTH(ByVal year As String) As String
        If CType(year, Integer) > 2500 Then
            year -= 543
        End If
        Return year
    End Function
    Public Shared Function ConvertDateToTH(ByVal day As String, ByVal month As String, ByVal year As String) As String
        Dim dt As Date
        If CType(year, Integer) > 2500 Then
            year -= 543
        End If
        dt = New Date(CType(year, Integer), CType(month, Integer), CType(day, Integer))
        Return dt
    End Function
    Public Shared Function DateIsValid(ByVal Contents As String) As Boolean
        Try
            'Dim myRegEx As New Regex("^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$")
            Dim myRegEx As New Regex("^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20|25)\d\d$")
            Dim myMatch As Match
            myMatch = myRegEx.Match(Contents)
            If myMatch.Success _
              AndAlso myMatch.Index = 0 _
              AndAlso myMatch.Length = Contents.Length Then
                Return True
            Else
                Return False
            End If
        Catch
            Return False 'some form of error in parsing the pattern
        End Try
  End Function
  Public Shared Function GetScreenWith() As Integer
    Dim intX As Integer = Screen.PrimaryScreen.Bounds.Width
    Return intX
  End Function
  Public Shared Function GetScreenHeight() As Integer
    Dim intY As Integer = Screen.PrimaryScreen.Bounds.Height
    Return intY
  End Function

End Class
